export const dispatchEventStorage = () => {
    const setItem = localStorage.setItem;
    const removeItem = localStorage.removeItem;

    localStorage.setItem = function (key, value) {
        let setEvent = new Event("setItemEvent");
        setEvent.key = key;
        setEvent.newValue = value;
        window.dispatchEvent(setEvent);
        setItem.apply(this, arguments);
    }

    localStorage.removeItem = function (key) {
        let removeEvent = new Event("removeItemEvent");
        removeEvent.key = key;
        window.dispatchEvent(removeEvent);
        removeItem.apply(this, arguments);
    }
}
